#!/usr/bin/env python
import dynamic_reconfigure.parameter_generator_catkin as dynamic_reconfigure
import os
import math

PACKAGE = "task_generator"

group_name_ = ""
group_bit_ = 0x1

def new_group(name):
    global group_name_, group_bit_
    group_name_ = str(name).replace("_", "")
    group_bit_ <<= 1
    return group_name_

def prefix(*args):
    global group_name_
    return str(group_name_) + "_" + "_".join(str(arg).replace("_", "") for arg in args)

gen = dynamic_reconfigure.ParameterGenerator()

gen.add("timeout", dynamic_reconfigure.double_t, group_bit_, f"episode timeout in seconds", 60)
gen.add("episodes", dynamic_reconfigure.int_t, group_bit_, f"desired episodes", -1)

gen.add("goal_radius", dynamic_reconfigure.double_t, group_bit_, f"default maximum distance from goal", 1.0)
gen.add("goal_tolerance_angle", dynamic_reconfigure.double_t, group_bit_, f"default maximum angle deviation from goal", 30 * math.pi/180)


group = gen.add_group(new_group("SCENARIO"))
group.add(prefix("file"), dynamic_reconfigure.str_t, group_bit_, "scenario file name", "default.json")

group = gen.add_group(new_group("PARAMETRIZED"))
group.add(prefix("file"), dynamic_reconfigure.str_t, group_bit_, "parametrized XML name", "default.xml")

group = gen.add_group(new_group("STAGED"))
group.add(prefix("curriculum"), dynamic_reconfigure.str_t, group_bit_, "curriculum file name", "default.yaml")
group.add(prefix("index"), dynamic_reconfigure.int_t, group_bit_, "starting stage", 0, 0)

group = gen.add_group(new_group("DYNAMICMAP"))

group = gen.add_group(new_group("RANDOM"))
for obstype in ["static", "interactive", "dynamic"]:
    group.add(prefix(obstype, "min"), dynamic_reconfigure.int_t, group_bit_, f"{obstype} min", 0, 0)
    group.add(prefix(obstype, "max"), dynamic_reconfigure.int_t, group_bit_, f"{obstype} max", 0, 0)
    group.add(prefix(obstype, "models"), dynamic_reconfigure.str_t, group_bit_, f"{obstype} models", "")
group.add(prefix("seed"), dynamic_reconfigure.int_t, group_bit_, f"random seed", -1)

group = gen.add_group(new_group("ZONES"))
group.add(prefix("scenario"), dynamic_reconfigure.str_t, group_bit_, "zones scenario file name", "default.yaml")
# group.add(prefix("file"), dynamic_reconfigure.str_t, group_bit_, "zones zones file name", "default.yaml")

exit(gen.generate(PACKAGE, "configuration", "TaskGenerator"))
